<?php
require './vendor/autoload.php';


//$client = new \WebSocket\Client('ws://127.0.0.1:8888');
//$client->text("woshifanjie");
//echo $client->receive();
//sleep(2000);
//$client->close();



$factory = new \Socket\Raw\Factory();
//$socket = $factory->createClient('127.0.0.1:8888');
$socket = $factory->createClient('127.0.0.1:1000');
echo 'Connected to ' . $socket->getPeerName() . PHP_EOL;
while (1){
    $data = $socket->read(4096);
    echo bin2hex($data);
    sleep(1);
    var_dump($data);
}
//00
//04
//70
//69
//6e
//67
//echo chr(hexdec("00"));
//echo chr(hexdec("04"));
//echo chr(hexdec("70"));
//echo chr(hexdec("69"));
//echo chr(hexdec("6e"));
//echo chr(hexdec("67"));
//echo chr(0x00);
//echo chr(0x05);
//echo chr(hexdec("00"));
//echo chr(hexdec("05"));
//echo chr(hexdec("73"));
//echo chr(hexdec("77"));
//echo chr(hexdec("69"));
//echo chr(hexdec("6e"));
//echo chr(hexdec("67"));
//0005
//73
//77
//69
//6e
//67
